package org.compiere.model;

import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
import java.util.logging.Level;

import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;

public class Mhrmmilitaryregistration extends X_hrm_militaryregistration {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -8010268503487721646L;
	
	/**	Static Logger	*/
	private static CLogger	s_log	= CLogger.getCLogger (Mhrmmilitaryregistration.class);

	public Mhrmmilitaryregistration(Properties ctx,
			int hrm_militaryregistration_ID, String trxName) {
		super(ctx, hrm_militaryregistration_ID, trxName);
	}

	public Mhrmmilitaryregistration(Properties ctx, ResultSet rs, String trxName) {
		super(ctx, rs, trxName);
	}

	public static Mhrmmilitaryregistration getMilitaryRegistration(int C_BPartner_ID){
		
		Mhrmmilitaryregistration hrmMilitary = new Mhrmmilitaryregistration(Env.getCtx(),0,null);
		//
	    PreparedStatement pstmt = null;
		ResultSet rs = null;
			
		// Data models Militaryregistration
		String sql_ = "SELECT * FROM HRM_MILITARYREGISTRATION " +
				"WHERE AD_CLIENT_ID=? " +
				"AND ISACTIVE='Y' " +
				"AND C_BPARTNER_ID=?";
			try
			{
				pstmt = DB.prepareStatement(sql_,null);
				pstmt.setInt(1, Env.getAD_Client_ID(Env.getCtx()));
				pstmt.setInt(2, C_BPartner_ID);
				rs = pstmt.executeQuery();	
				if(rs.next())
					hrmMilitary = new Mhrmmilitaryregistration(Env.getCtx(), rs, null);
			}
			catch (SQLException e)
			{
				s_log.log(Level.SEVERE, "Error --> "+ e.getMessage());
			}
			finally
			{
				DB.close(rs, pstmt);
				rs = null; pstmt = null;
			}	
		
		
		return hrmMilitary;
	}

}
